package com.xbongbong.paas.domain.entity;

import com.xbongbong.paas.enums.BusinessRuleExecuteEnum;
import com.xbongbong.paas.enums.DelEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2020/5/9 16:31
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class BusinessRuleLogEntity implements Serializable {
    private static final long serialVersionUID = 8132875279222398796L;


    //========== properties ==========

    /**
     * 主键
     */
    private Long id;

    /**
     * 公司id
     */
    private String corpid;

    private Integer saasMark;
    /**
     * 当前表单业务类型
     */
    private Integer businessType;
    /**
     * 当前表单id
     */
    private Long formId;

    /**
     * 改动的数据id
     */
    private Long dataId;

    private Integer targetSaasMark;

    /**
     * 目标表单业务类型
     */
    private Integer targetBusinessType;

    /**
     * 目标表单
     */
    private Long targetFormId;


    private String redisKey;
    /**
     * 报错原因（1：自身错误；2：被动错误）
     * @see BusinessRuleExecuteEnum
     */
    private Integer reason;

    /**
     * 报错信息
     */
    private String reasonMessage;

    /**
     * 是否被消费（0：未消费；1：消费成功）
     */
    private Integer consumer;

    /**
     * 执行动作（1：仅更新；2：仅添加；3：更新和插入数据；4：仅删除）
     */
    private Integer performAction;

    /**
     * 执行结果（1：仅更新；2：仅添加；4：仅删除）
     */
    private Integer executeResult;

    /**
     * 执行条数
     */
    private Integer executeNum;

    /**
     * 业务规则信息id
     */
    private Long businessRuleInfoId;

    /**
     * 执行类型（1：生效；2：失效）
     */
    private Integer businessRuleType;

    /**
     * 创建者userId
     */
    private String creatorId;

    /**
     * 创建时间时间戳
     */
    private Long addTime;

    /**
     * 更新时间时间戳
     */
    private Long updateTime;

    /**
     * 删除标记
     */
    private Integer del;

    public BusinessRuleLogEntity() {
        this.del = DelEnum.NORMAL.getDel();
    }

    public BusinessRuleLogEntity(String corpid, Integer saasMark, Integer businessType, Long formId, Long dataId, Integer targetSaasMark,
                                 Integer targetBusinessType, Long targetFormId, Integer reason, String reasonMessage, Integer consumer,
                                 Integer performAction, Integer executeResult, Integer executeNum, Long businessRuleInfoId, Integer businessRuleType,
                                 String creatorId, String redisKey) {
        this.corpid = corpid;
        this.saasMark = saasMark;
        this.businessType = businessType;
        this.formId = formId;
        this.dataId = dataId;
        this.targetSaasMark = targetSaasMark;
        this.targetBusinessType = targetBusinessType;
        this.targetFormId = targetFormId;
        this.reason = reason;
        this.reasonMessage = reasonMessage;
        this.consumer = consumer;
        this.performAction = performAction;
        this.executeResult = executeResult;
        this.executeNum = executeNum;
        this.businessRuleInfoId = businessRuleInfoId;
        this.businessRuleType = businessRuleType;
        this.creatorId = creatorId;
        this.del = DelEnum.NORMAL.getDel();
        this.redisKey = redisKey;
    }

    public BusinessRuleLogEntity(Long id, String corpid, Integer consumer, Integer del) {
        this.id = id;
        this.corpid = corpid;
        this.consumer = consumer;
        this.del = del;
    }
}
